﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using E_Shop.Common;
using ESHOP.DAO;
using ESHOP.Domain;
using ESHOP.UTIL;
namespace E_Shop
{
    public partial class SiteRegister : Authentication
    {

        private readonly  AccountDAO _accountdao = new AccountDAO();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Loadreference();
            }
        }

        private void Loadreference()
        {
            CommonFunc.BindDropDownList(ddlregion,new QuocGiaDAO().GetList(),"TENQUOCGIA","ID",true);
        }
        protected void btnOk_Click(object sender, EventArgs e)
        {
            ACOUNT _acount= new ACOUNT();
            _acount.USERNAME = txtloginname.Text.Trim();
            _acount.PASS = txtpass.Text.Trim();
            _acount.MAQG = ddlregion.SelectedValue;
            _acount.ISACTIVE = true;
            _acount.JOBTITLE = txtJob.Text.Trim();
            _acount.PHONE = txtPhone.Text.Trim();
            _acount.EMAIL = txtEmail.Text.Trim();
            _acount.CONTACTDDRESS = txtcontactaddress.Text.Trim();
            if (_accountdao.Insert(_acount) == 1)
            {
                ShowInfor_sitermaster("Register account success.");
                Session[Constants.SESSION_LOGIN] = _acount;
                Response.Redirect(WebUrl.BUSINESS_HOME, true);
            }
            else
            {
                ShowError_sitermaster("Register account fail!");
            }
        }
    }
}